function setCookie(key, value, expires) {
    if (typeof expires === "object") {
        document.cookie = `${key}=${value};expires=${expires}`
    }
    if (typeof expires === "number") {
        let date = new Date();
        date.setDate(date.getDate() + expires);
        document.cookie = `${key}=${value};expires=${date}`
    }
}

function getCookie(k) {
    let result = {}
    let arr = document.cookie.split("; ");
    arr.forEach(item => {
        let key = item.split("=")[0];
        let value = item.split("=")[1];
        result[key] = value;
    })

    if (!k) {
        return result;
    }
    return result[k];
}